const BASE_URL = 'http://1.15.187.207:3000'

/**
 * 二次封装网络请求
 */
class DYRequest {
    static request(url, method, params) {
        return new Promise((resolve, reject) => {
            wx.request({
                url: `${BASE_URL}${url}`,
                data: params,
                method: method,
                success: res => resolve(res.data),
                fail: err => reject(err)
            })
        })
    }

    static get(url, params) {
        return this.request(url, 'GET', params)
    }

    static post(url, data) {
        return this.request(url, 'POST', data)
    }
}

export default DYRequest